import mainRoot from "../../Game/MainRoot";
import level_bunchbunchbunch from "./leve_bunchbunchbunch";

const {ccclass, property} = cc._decorator;

@ccclass
export default class level_bunchAnimalItem extends cc.Component {

    @property({type:cc.Node,tooltip:"icon节点"})
    icon:cc.Node = null;

    @property({type:cc.Label})
    lb:cc.Label = null;

    animalType:string = "";

    level:level_bunchbunchbunch = null;

    bindType(animalType:string,level:level_bunchbunchbunch){
        this.animalType = animalType;
        this.lb.string = this.animalType;
        this.level = level;
        this.loadAnimal();
    }

    loadAnimal(){
        let spPath = this.level.spPathAry[Number(this.animalType)];
        mainRoot.LevelSystem.getOneTypeBundle(this.level.getLevelInfo().levelType).load(`animal/${spPath}`,cc.SpriteFrame,(err,spr:cc.SpriteFrame)=>{
            if(err){
                console.log(err,"加载图片失败");
                return;
            }
            this.icon.getComponent(cc.Sprite).spriteFrame = spr;
        });
    }

}
